package com.joyoung.common.api;

import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;
import com.joyoung.common.utils.FormatUtil;


/**
 * 统一的http请求结果封装，所有请求实体类的基类
 * Created by zhangdroid on 2017/7/26.
 */
@SuppressWarnings({"WeakerAccess", "unused"})
public class BaseResponse<T> {
    
    // 请求成功返回码
    private static final String CODE_SUCCESS = "0";
    @SerializedName("data")
    private T result;// 结果对象
    
    private String code;// 结果码
    private String description;// 返回结果描述
    
    public String getCode() {
        return FormatUtil.formatEmpty(code);
    }
    
    public void setCode(String code) {
        this.code = code;
    }

    public String getDescription() {
        return FormatUtil.formatEmpty(description);
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public T getResult() {
        return result;
    }
    
    public void setResult(T result) {
        this.result = result;
    }
    
    public boolean isSucceed() {
        return (!TextUtils.isEmpty(code) && CODE_SUCCESS.equals(code));
    }

}
